package com.kiki.song.mapper;

import java.util.List;

import com.kiki.song.domain.main.LikeType;
import com.kiki.song.domain.main.Song;
import com.kiki.song.domain.main.SongDTO;
import com.kiki.song.domain.main.SongVo;
import com.kiki.song_category.domain.SongCategory;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 音乐信息Mapper接口
 * 
 * @author 林志毅
 * @date 2025-01-08
 */
public interface SongMapper 
{
    /**
     * 查询音乐信息
     * 
     * @param songId 音乐信息主键
     * @return 音乐信息
     */
    public Song selectSongBySongId(Long songId);

    /**
     * 查询音乐信息列表
     * 
     * @param song 音乐信息
     * @return 音乐信息集合
     */
    public List<Song> selectSongList(Song song);

    /**
     * 新增音乐信息
     * 
     * @param song 音乐信息
     * @return 结果
     */
    public int insertSong(Song song);

    /**
     * 修改音乐信息
     * 
     * @param song 音乐信息
     * @return 结果
     */
    public int updateSong(Song song);

    /**
     * 删除音乐信息
     * 
     * @param songId 音乐信息主键
     * @return 结果
     */
    public int deleteSongBySongId(Long songId);

    /**
     * 批量删除音乐信息
     * 
     * @param songIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteSongBySongIds(Long[] songIds);

    List<Song> selectSongListByAlbumId(Long albumId);

    @Select("select * from song where singer = #{singer}")
    List<Song> getSongListBySingerId(String singer);

    @Select("select song_id from song group by song_id")
    List<Long> getAllSongIds();


    @Select("select song_name from song where song_id = #{songId}")
    String getSongNameBySongId(Long songId);


    @Select("select * from song where song_id = #{songId}")
    Song getSongBySingerId(int songId);
    @Select("SELECT DISTINCT type FROM song")
    List<String> getMusicType();

    @Update("UPDATE sys_user\n" +
            "SET like_type = #{likeType}\n" +
            "WHERE user_id = #{userId};\n")
    Boolean addLikeType(LikeType likeType);
    @Select("SELECT like_type FROM sys_user WHERE user_id = #{userId}")
    String getUserLikeTypeByUserId(int userId);

    @Select("SELECT * FROM song WHERE type= #{type}")
    List<Song> getSongListByType(String type);

    /**
     * 获取最近一个月的新歌
     * @return
     */
    @Select("SELECT * FROM song WHERE release_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH)")
    List<Song> getNewSongs();

    @Select("SELECT COUNT(*) FROM song WHERE type = #{songType}")
    int getTypeSongCount(String songType);
}
